package com.ruoyi.system.api.produce.service.impl;

import com.ruoyi.system.api.model.dto.SysLoginLogDto;
import com.ruoyi.system.api.model.dto.SysOperLogDto;
import com.ruoyi.system.api.service.ILogApiService;
import com.ruoyi.system.domain.SysLoginLog;
import com.ruoyi.system.domain.SysOperLog;
import com.ruoyi.system.service.ISysLoginLogService;
import com.ruoyi.system.service.ISysOperLogService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LogApiService implements ILogApiService {

    @Autowired
    ISysOperLogService sysOperLogService;

    @Autowired
    ISysLoginLogService sysLoginLogService;

    @Override
    public SysOperLogDto saveLog(SysOperLogDto sysOperLogDto) {
        SysOperLog operLog = new SysOperLog();
        BeanUtils.copyProperties(sysOperLogDto, operLog);
        sysOperLogService.insertOperlog(operLog);
        BeanUtils.copyProperties(operLog, sysOperLogDto);
        return sysOperLogDto;
    }

    @Override
    public SysLoginLogDto saveLoginLog(SysLoginLogDto sysLoginLogDto) {
        SysLoginLog sysLoginLog = new SysLoginLog();
        BeanUtils.copyProperties(sysLoginLogDto, sysLoginLog);
        sysLoginLogService.insertLoginLog(sysLoginLog);
        BeanUtils.copyProperties(sysLoginLog, sysLoginLogDto);
        return sysLoginLogDto;
    }
}
